package cn.wolfcode.shop.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;

import cn.wolfcode.shop.domain.UserLogin;
import cn.wolfcode.shop.service.ICarService;
import cn.wolfcode.shop.vo.CarVo;
import cn.wolfcode.shop.vo.JSONResult;

@RestController
@RequestMapping("/api/cars")
public class CarController {

	@Reference
	private ICarService carService;

	/**
	 * 添加商品到购物车
	 * 路径:/api/cars/
	 * 方法:POST
	 * 自定义参数解析,目的是为了获取userLogin,很多地方都需要这些判断
	 * @return
	 */
	@PostMapping
	//	public JSONResult addCar(HttpServletRequest request,CarVo carVo) {
	public JSONResult addCar(UserLogin userLogin, CarVo carVo) {
//		String token = request.getHeader("head_token");
//		carVo.setToken(token);
		carService.addCar(userLogin,carVo);
		return new JSONResult();
	}

}
